package com.zyz.K_集合.collection接口;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class TestCollectionAdd {
    public static void main(String[] args) {
        //ArrayList 是 Collection的子接口 List的实现类之一
        Collection collection = new ArrayList();
        collection.add(111);
        collection.add(222);
        collection.add("vick");
        collection.add(new String("aaaa"));
        System.out.println(collection);
        System.out.println("=======");

        Collection c1 = new ArrayList();
        c1.add("111");
        c1.add(222);
        System.out.println(c1);
        System.out.println("c1集合元素的个数：" + c1.size());

        Collection c2 = new ArrayList();
        c2.add("vick");
        c2.add("abc");
        System.out.println(c2);
        System.out.println("c2集合元素的个数：" + c2.size());

        System.out.println("====将c2集合的所有元素添加到c1集合中==");
        c1.addAll(c2);
        System.out.println(c1);
        System.out.println("c1集合元素的个数：" + c1.size());
    }
}
